import { Badge,Tooltip } from 'antd';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
export default class GovernBadge extends React.Component{

    render() {
        return(
            <div className = "g-governBadge">
                {this.getBadge()}
            </div>
        )
    }
    getBadge = () => {
        const { record,text } = this.props;
        let start = record.enddatespan.indexOf("|")+1;
        let str = record.enddatespan.split("|");
        let date = str[1];
        let status = str[2];
        let statusText = ""//提示信息的文字
        let colorBack = ""//Badge天数背景色
        if (date > 0 &&  status === "0") {//未开始  0
            statusText = getLabel('30144,24980,15086',"距离结束日期还有");
            colorBack = '#ff9000';
            return this.getBadgeItem(date,text,statusText,colorBack);
        } else if (date > 0 &&  status === "1") {//进行中 1
            statusText = getLabel('30144,24980,15086',"距离结束日期还有");
            colorBack = '#2db7f5';
            return this.getBadgeItem(date,text,statusText,colorBack);
        } else if (date < 0 && status === "2") {//已超期 2
            statusText = getLabel(21984,"已超期");
            colorBack = '#f50';
            return this.getBadgeItem(date,text,statusText,colorBack);
        } else if (status  === "3") {//已完成 3
            return <div>{text}</div>;
        } else if (status  === "4") {//已废弃 4
            return <div>{text}</div>;
        }else if (status  === "5") {//已删除 5
            return <div>{text}</div>;
        }else{
            return <div>{text}</div>;
        }
    }
    getBadgeItem = ( date,text,statusText,colorBack) => {
        return (
                <Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@rvnoly`} placement="right" title={<span>{`${statusText}${Math.abs(date)}${getLabel('1925',"天")}`}</span>}>
                    <Badge ecId={`${this && this.props && this.props.ecId || ''}_Badge@niljk6`} count={Math.abs(date)} style={{background:'#fff', color:`${colorBack}`, border: `1px solid ${colorBack}`,marginLeft:'26px',borderRadius:'3px',marginTop:'5px',zIndex:'0',fontSize :'13px' }} overflowCount={999}>
                            <span>{text}</span>
                    </Badge>
                </Tooltip>
                );
    }
}
